<?

//根据页面数量信息，筛选信息，创造url，供页码,跳转等使用
include_once("model/set_url.php");



//处理数据并且update
//获取数据

$con = '';

if($_REQUEST['ai_unit_nid'] != ''){
    $con = "and nid = '".$_REQUEST['ai_unit_nid']."'";
}

//查找单位
$unit_list = select_one_line_all_items($table_Prefix . "unit", "name ='".$_REQUEST['ai_unitname']."'".$con);
//判断单位名称是否为空防止前台啥都没输入就新增了单位
if($_REQUEST['ai_unitname'] != '' && $unit_list == ''){
    $data['ai_name'] = $_REQUEST['ai_unitname'];
    $sql = insert_date($table_Prefix."unit",$data);
    $query = mysql_query($sql) or die ($sql);
    //获取最新一条数据
    $find_latest_unit= select_one_line_all_items($table_Prefix."unit","nid = (SELECT MAX(nid) FROM ".$table_Prefix."unit".")");
    $_REQUEST['ai_unit_nid'] = $find_latest_unit['nid'];
}

//移除单位字段
unset($_REQUEST['ai_unitname']);

$sql=update_date($table_prefix."opportunity",$_REQUEST,"nid",$_REQUEST['nid']);
$query = mysql_query($sql) or die ("error:".mysql_error());

?>

